<?php
    header("Content-type:text/html;charset=utf-8");
    include "Model.php";
    echo "<pre>";
    $conn =new Mysql('preferredshares','oc_user_org');
            $sql  = 'select  uid as client_id , equity , certificate, createtime as create_time ,equity_time as  confirm_time,ic.id as init_comp_id, cm.id as management_id ,cp.id as partner_id
            from oc_user_org as o
            left join client_management        as cm on o.uid = cm.client_id 
            left join client_initiator_company as ic on o.uid = ic.client_id and ic.client_id =cm.client_id 
            left join client_partner           as cp on o.uid = cp.client_id and cp.client_id =ic.client_id
            where type=5'; 
            $res =$conn->getAll($sql);
            //var_dump($res);
            //exit;
            $conn1 =  new Mysql('preferredshares','client_financial_planner'); 
            foreach ($res as $k =>$v){
                $data =array();
                $data['client_id'] =$v['client_id'];
                $data['is_planner'] =$v['certificate']==Null ? 0 : 1;
                $data['is_qualified'] =$v['equity']==Null ? 0 : 1;
                $data['create_time']  =$v['create_time']==0 ? Null:date('Y-m-d H:i:s',$v['create_time']);
                $data['confirm_time']  =$v['confirm_time']==Null ? Null:date('Y-m-d H:i:s',$v['confirm_time']);
                $data['partner_id']   =$v['partner_id'];
                $data['init_comp_id'] = $v['init_comp_id'];
                $data['management_id'] = $v['management_id'];
                $data['update_time']     =Null; 
                //$res=$conn1->insert($data);
                // var_dump($data);
                //exit;
            } 
    echo '<script>alert("插入数据库成功")</script>';